import hashlib
def calculate_model_hash(model):
        """计算模型参数的哈希值"""
        hash_dict = {}
        for name, param in model.named_parameters():
            # 转换为numpy数组并计算哈希
            param_np = param.detach().cpu().numpy()
            hasher = hashlib.sha256()
            hasher.update(param_np.tobytes())
            hash_dict[name] = hasher.hexdigest()[:8]  # 取前8位简化显示
        return hash_dict